<?php include_once 'layout/heard.php'?>
<body style="background:#f5f5f5; padding-bottom:45px;">

<div class="content head_bg">
	<div class="head">
        <a href="javascript:void(0)" class="return_ico" onclick="javascript:history.go(-1);"><span></span></a>
        <h1>订单详情</h1>
    </div>
</div>

<div class="nav_hs"></div>
<div class="nav_bg">
    <div class="nav_com">
        <dl>
            <dd><img src="webroot/riders/images/logo.png"></dd>
            <dt><?php echo $_SESSION['riders']['tel']?></dt>
        </dl>
        <ul>
            <li><a class="grxx" href="?md=riders&cl=riders&at=personageInfo">个人信息</a></li>
            <li><a class="lsdd" href="?md=riders&cl=riders&at=orderHistory">历史订单</a></li>
            <li><a class="wdqb" href="?md=riders&cl=riders&at=myWallet">我的钱包</a></li>
            <li><a class="cjwt" href="?md=riders&cl=riders&at=FQA">常见问题</a></li>
            <li><a class="xxzx" href="?md=riders&cl=riders&at=messageConten">消息中心</a></li>
        </ul>
    </div>
</div>
<div class="content order_xx_top">
    <div class="com">
        <div class="mdxx">
            <h3><?php echo $orderExpressInfo['shopInfo']['storename'] ?></h3>
            <p><?php echo $orderExpressInfo['shopInfo']['address'] ?></p>
            <a href="tel:<?php echo $orderExpressInfo['shopInfo']['tel'] ?>"></a>
        </div>
        <div class="shrxx">
            <h3><?php echo $orderExpressInfo['orderInfo']['receiver'] ?></h3>
            <p><?php echo $orderExpressInfo['orderInfo']['receiver_address'] ?></p>
            <a href="tel:<?php echo $orderExpressInfo['orderInfo']['receiver_tel'] ?>"></a>
            <p><?php echo '配送距离：'. round($orderExpressInfo['orderInfo']['distance']/1000,2).'公里';   ?></p>
        </div>
    </div>
</div>

<div class="content order_xx_com">
    <ul>
        <li>
            <p>最迟到店</p>
            <span><?php echo $orderExpressInfo[0]['shop_pickup_time'] ?> 前取货</span>
        </li>
        <li>
            <p>最迟送达</p>
            <span><?php echo $orderExpressInfo[0]['shop_delivery_time'] ?> 前送达</span>
        </li>
        <li>
            <p>订单号</p>
            <span><?php echo $orderExpressInfo[0]['shop_express_no'] ?></span>
        </li>
        <li>
            <p>订单收入</p>
            <b>￥ <?php echo $orderExpressInfo[0]['express_fee'] ?></b>
        </li>
        <?php

        if($orderExpressInfo[0]['tip_arr'] && count($orderExpressInfo[0]['tip_arr']) > 0){
            if(count($orderExpressInfo[0]['tip_arr']) > 1){
                $c = '($k+1)';
            }else{
                $c = '';
            }
            foreach($orderExpressInfo[0]['tip_arr'] as $k=>$tip){
                $tip_remark .= isset($tip['tip_remark']) ? $c.' '.$tip['tip_remark'] :''.' ';
                echo '<li>
                    <p>配送小费</p>
                    <b>￥ '.$tip['price'].'</b>
                </li>';

                echo '<li>
                    <p>配送小费备注</p>
                    <b>'.$tip_remark.'</b>
                </li>';
            }
        }
        ?>

        <li>
            <p>指派备注</p>
            <b> <?php echo $orderExpressInfo[0]['shop_express_remark'] ?></b>
        </li>

    </ul>
</div>


<div class="content order_xx_com">
    <ul>
        <li><p style="color:#333; font-weight:bold">商品信息：</p></li>
        <?php foreach($orderExpressInfo['orderProductInfo'] as $op){
            echo ' <li><p>'.$op['product_name'].'</p><span>× '.$op['qty'].'</span></li>	';
        }?>
        <li>
            <p>共计：</p>
            <span><?php echo count($orderExpressInfo['orderProductInfo'])?>件</span>
        </li>
    </ul>
</div>


<!--待取货-->
<?php if($t == 3) {
    echo '<div class="order_xx_bnt">
    <div class="content">
        <a class="bnt_wfps" href="javascript:void(0)">无法配送</a>
        <a class="bnt_right bnt_qrqh" code="'.$orderExpressInfo[0]['id'].'"  href="javascript:void(0)">确认取货</a>
    </div>
</div>

<div class="group_tc_bg" id="qrqh_pop">
    <div class="group_tc">
        <h3>温馨提示！</h3>
        <p>请到门店拿到商品确认无误后，再按确认取货，虚假按确认取货将会被平台惩罚哦！</p>
        <div class="bnt">
            <a href="javascript:void(0)" class="btn1">还未到店</a>
            <a href="javascript:void(0)" class="btn2">确认取货</a>
            <p style="display: none" >1</p>
        </div>
    </div>
</div>

<div class="group_tc_bg" id="wfps_pop">
    <div class="group_tc">
        <h3>温馨提示！</h3>
        <p>目前无法自动取消配送订单，只能拨打门店电话，让门店操作取消订单。</p>
        <div class="bnt">
            <a href="javascript:void(0)" class="btn1">继续配送</a>
            <a href="tel:'.$orderExpressInfo['shopInfo']['tel'].'" class="btn2">拨打门店电话</a>
        </div>
    </div>
</div>';
}?>


<!--待配送-->
<?php if($t == 4){
echo '<div class="order_xx_bnt">
    <div class="content">
        <a style="width:100%;" class="bnt_right bnt_hpsd" code="'.$orderExpressInfo[0]['id'].'" href="javascript:void(0)">货品送达</a>
    </div>
</div>

<div class="group_tc_bg" id="hpsd_pop">
    <div class="group_tc">
        <h3>温馨提示！</h3>
        <p>请确认货品已送达，如发现虚假按货品送达将面临50元一次惩罚！</p>
        <div class="bnt">
            <a href="javascript:void(0)" class="btn1">还未送达</a>
            <a href="javascript:void(0)" class="btn2">确认送达</a>
        </div>
    </div>
</div>

<div class="group_tc_bg" id="hpsd_qr_pop">
    <div class="group_tc">
        <h3>订单配送完成确认</h3>
        <div class="com">
            <div class="box">
                <label>订单配送情况：</label>
                <select name="finishSelect" id="finishSelect">
                    <option value="">请选择</option>
                    <option value="1">本人签收</option>
                    <option value="2">家人/门卫代签</option>
                    <option value="6">异常订单</option>
                </select>
            </div>
            <div class="box">
                <label>骑手备注：</label>
                <textarea class="text" name="remark" id="remark"></textarea>
            </div>
        </div>
        <div class="bnt">
            <a href="javascript:void(0)" class="btn1">取消</a>
            <a href="javascript:void(0)" class="btn2">确认</a>
            <p style="display: none">1</p>
        </div>
    </div>
</div>';
}?>


<!--历史 完成-->
<?php if($t > 4){
echo '<div class="order_xx_bnt">
	<div class="content">
        <a style="width:100%;" class="bnt_right" href="javascript:history.go(-1);" >返回</a>
    </div>
</div>';
}?>



<?php include_once 'layout/rfooter.php'?>
<script>
    $("#hpsd_qr_pop .btn2").click(function(){
        var express_id = $(this).attr('code');
        var type = $(this).next().text();
        var finishSelect = $("#finishSelect").val();
        var remark = $("#remark").val();

        if(!finishSelect || !express_id){
            popup("请正确填写");
            return false;
        }
        if(!finishSelect){
            popup("订单签收状态不可为空");
            return false;
        }
        $.ajax({
            url:"?md=riders&cl=riders&at=finish",
            type:"post",
            dataType:"json",
            data:{'express_id':express_id,'finishSelect':finishSelect,'remark':remark},
            success:function (d) {
                $("#hpsd_qr_pop .btn1").click();
                if(d.status == 1){
                    popup("配送完成");
                    window.location.href = "?md=riders&cl=riders&at=dispatching";
                }else{
                    popup(d.msg);
                    // $("#qrqh_pop").fadeOut();
                }
            }
        })
    });
    $("#hpsd_qr_pop .btn1").click(function(){
        $("#hpsd_qr_pop").fadeOut();
    });
</script>